package com.pcitc.app.model;

import com.pcitc.app.model.BaseObject;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

import java.io.Serializable;

@Entity
@Table(name="TBL_USER_POSITION",schema="ADMIN")
public class TblUserPosition extends BaseObject implements Serializable {
    private Long prkid;
    private TblUser tblUser;
    private TblPosition tblPosition;
    
    public TblUserPosition(){
    	
    }
    
    public TblUserPosition(TblUser user,TblPosition position){
    	this.tblUser = user;
    	this.tblPosition = position;
    	user.getTblUserPositions().add(this);
    	position.getTblUserPositions().add(this);
    }
   

    @Id  @GeneratedValue(strategy = GenerationType.AUTO)    
    public Long getPrkid() {
        return this.prkid;
    }
    
    public void setPrkid(Long prkid) {
        this.prkid = prkid;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="USERID")
    public TblUser getTblUser() {
        return this.tblUser;
    }
    
    public void setTblUser(TblUser tblUser) {
        this.tblUser = tblUser;
    }
@ManyToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="POSITIONID")
    public TblPosition getTblPosition() {
        return this.tblPosition;
    }
    
    public void setTblPosition(TblPosition tblPosition) {
        this.tblPosition = tblPosition;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        TblUserPosition pojo = (TblUserPosition) o;

        if (tblUser != null ? !tblUser.equals(pojo.tblUser) : pojo.tblUser != null) return false;
        if (tblPosition != null ? !tblPosition.equals(pojo.tblPosition) : pojo.tblPosition != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (tblUser != null ? tblUser.hashCode() : 0);
        result = 31 * result + (tblPosition != null ? tblPosition.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("prkid").append("='").append(getPrkid()).append("', ");
        sb.append("tblUser").append("='").append(getTblUser()).append("', ");
        sb.append("tblPosition").append("='").append(getTblPosition()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
